
# # gtest库相关
# include_directories(../googletest/googletest/include)  # 包含gtest等头文件
# include_directories(../googletest/googlemock/include)  # 包含gmock等头文件

# add_subdirectory(add_test)


cmake_minimum_required(VERSION 3.10)
project(YourProjectName)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 包含头文件目录
include_directories(
    ../googletest/googletest/include    # gtest头文件
    ../googletest/googlemock/include     # gmock头文件
    ../../operator/add                   # 你的操作符头文件
)

# 查找gtest/gmock库文件
find_library(GTEST_LIB 
    NAMES gtest libgtest.a
    PATHS ../googletest/build/lib
    NO_DEFAULT_PATH
)

find_library(GTEST_MAIN_LIB 
    NAMES gtest_main libgtest_main.a
    PATHS ../googletest/build/lib
    NO_DEFAULT_PATH
)

find_library(GMOCK_LIB 
    NAMES gmock libgmock.a
    PATHS ../googletest/build/lib
    NO_DEFAULT_PATH
)

find_library(GMOCK_MAIN_LIB 
    NAMES gmock_main libgmock_main.a
    PATHS ../googletest/build/lib
    NO_DEFAULT_PATH
)

# 检查是否找到所有必需的库
if(NOT GTEST_LIB OR NOT GTEST_MAIN_LIB OR NOT GMOCK_LIB OR NOT GMOCK_MAIN_LIB)
    message(FATAL_ERROR "无法找到Google Test/Mock库文件，请确保它们已编译")
endif()

# 创建库变量供下层使用
set(GTEST_LIBRARIES 
    ${GTEST_LIB}
    ${GTEST_MAIN_LIB} 
    ${GMOCK_LIB}
    ${GMOCK_MAIN_LIB}
    pthread
    CACHE INTERNAL "Google Test/Mock libraries"
)

# 添加子目录
add_subdirectory(add_test)